package com.yidao.template.service.impl;

import java.io.InputStream;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yidao.core.service.impl.BaseDomainObjectServiceImpl;
import com.yidao.repository.service.RepositoryService;
import com.yidao.template.domain.Template;
import com.yidao.template.service.TemplateService;

@Service
public class TemplateServiceImpl extends BaseDomainObjectServiceImpl<Template> implements TemplateService{
	
	@Autowired
	private RepositoryService repositoryService;
	
	@Transactional
	@Override
	public void create(Template template, InputStream in) {
		this.repositoryService.putObject(template.getName(), "templates", in);
		super.create(template);
	}

	@Transactional
	@Override
	public void update(Template template, InputStream in) {
		this.repositoryService.removeObject(template.getName(), "templates");
		this.repositoryService.putObject(template.getName(), "templates", in);
		super.update(template);
	}
}
